//
//  AppDelegate.m
//  PersonalNews
//
//  Created by Golibyo on 15/11/26.
//  Copyright © 2015年 changshuhua. All rights reserved.
//

#import "AppDelegate.h"
#import "LCZNewsViewController.h"
#import "DEMOLeftMenuViewController.h"
#import "LWHScrollVC.h"
#import "LCZNewsViewController.h"

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor whiteColor];
    LCZBaseImageView *backImage = [[LCZBaseImageView alloc]initWithFrame:CGRectMake(0, 0, self.window.frame.size.width, self.window.frame.size.height)];
    [self.window addSubview:backImage];
    backImage.image = [UIImage imageNamed:@"b1.jpg"];
    
    LCZNewsViewController *rootVC = [[LCZNewsViewController alloc]init];
    UINavigationController *nVC = [[UINavigationController alloc] initWithRootViewController:rootVC];
    
    
    DEMOLeftMenuViewController *leftMenuViewController = [[DEMOLeftMenuViewController alloc] init];
    RESideMenu *sideMenuViewController = [[RESideMenu alloc] initWithContentViewController:nVC leftMenuViewController:leftMenuViewController rightMenuViewController:nil];
    sideMenuViewController.menuPreferredStatusBarStyle = 1; // UIStatusBarStyleLightContent
    sideMenuViewController.delegate = self;
    sideMenuViewController.contentViewShadowColor = [UIColor blackColor];
    sideMenuViewController.contentViewShadowOffset = CGSizeMake(0, 0);
    sideMenuViewController.contentViewShadowOpacity = 0.6;
    sideMenuViewController.contentViewShadowRadius = 12;
    sideMenuViewController.contentViewShadowEnabled = YES;
    self.window.rootViewController = sideMenuViewController;
    [self.window makeKeyAndVisible];
    // Override point for customization after application launch.
    
    
    // 友好界面
    CGSize size = [UIScreen mainScreen].bounds.size;
    
    UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, size.width, size.height)];
    imageView.image = [UIImage imageNamed:@"fine.jpg"];
    
    [self.window addSubview:imageView];
    
    [UIView animateWithDuration:2 delay:2 options:UIViewAnimationOptionCurveEaseInOut animations:^{
        imageView.alpha = 0;
        
    } completion:^(BOOL finished) {
        
        [imageView removeFromSuperview];
    }];
    
//    // 引导页
//    [self determineTheVersionNumber];
    
    return YES;
}

//#pragma mark - 判断版本号
//- (void)determineTheVersionNumber
//{
//    // 获取沙盒中的版本号
//    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
//    NSString *key = (__bridge_transfer NSString *)kCFBundleVersionKey;
//    NSString *sandBoxVersion = [defaults valueForKeyPath:key];
//    // 获取当前版本号
//    NSDictionary *md = [NSBundle mainBundle].infoDictionary;
//    NSString *currentVersion = md[key];
//    NSLog(@"--------%@", currentVersion);
//    
//
//    if ([currentVersion compare:sandBoxVersion] == NSOrderedDescending)
//    {
//        // 存储当前版本号
//        [defaults setObject:currentVersion forKey:key];
//        
//        
//        [defaults synchronize];
//        // 第一次使用当前版本  显示引导页
//        [self showGuidePage];
//    }
//    else
//    {
//        RESideMenu *newsVC = [[RESideMenu alloc]init];
//        // 不是第一次使用当前版本  显示主页面
////        [self.window setRootViewController:newsVC];
//        self.window.rootViewController = newsVC;
//    }
//}
//#pragma mark - 引导页
//- (void)showGuidePage
//{
//    LWHScrollVC *scroller = [[LWHScrollVC alloc] init];
//    [self.window setRootViewController:scroller];
//    
//}
//
//
#pragma mark RESideMenu Delegate

//- (void)sideMenu:(RESideMenu *)sideMenu willShowMenuViewController:(UIViewController *)menuViewController
//{
//    NSLog(@"willShowMenuViewController: %@", NSStringFromClass([menuViewController class]));
//}
//
//- (void)sideMenu:(RESideMenu *)sideMenu didShowMenuViewController:(UIViewController *)menuViewController
//{
//    NSLog(@"didShowMenuViewController: %@", NSStringFromClass([menuViewController class]));
//}
//
//- (void)sideMenu:(RESideMenu *)sideMenu willHideMenuViewController:(UIViewController *)menuViewController
//{
//    NSLog(@"willHideMenuViewController: %@", NSStringFromClass([menuViewController class]));
//}
//
//- (void)sideMenu:(RESideMenu *)sideMenu didHideMenuViewController:(UIViewController *)menuViewController
//{
//    NSLog(@"didHideMenuViewController: %@", NSStringFromClass([menuViewController class]));
//}


- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
    // Saves changes in the application's managed object context before the application terminates.
    
}


@end
